package cn.smbms.filter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import cn.smbms.pojo.User;
import cn.smbms.tools.Constants;

public class MyInterceptor extends HandlerInterceptorAdapter{
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		boolean falg = false;	//返回false
		System.out.println("进入了自定义拦截器 ：preHanle===============");
		// TODO Auto-generated method stub
		 User user = (User)request.getSession().getAttribute(Constants.USER_SESSION);
		if (null != user) {
			falg = true;
		}else {
			falg = false;
			response.sendRedirect(request.getContextPath()+"/401.jsp");
		}
		return falg; 
	}
}
